package com.edu.exam.enums.quality.monitoring;

import com.edu.exam.enums.core.StatusEnum;
import lombok.Getter;

/**
 * 监控任务状态枚举
 * 用于监控相关的任务状态管理
 */
@Getter
public enum MonitoringTaskStatus implements StatusEnum {
    
    CREATED("0", "已创建"),
    PENDING("1", "待处理"),
    IN_PROGRESS("2", "进行中"),
    COMPLETED("3", "已完成"),
    FAILED("4", "失败"),
    CANCELLED("5", "已取消"),
    TIMEOUT("6", "超时"),
    PAUSED("7", "已暂停"),
    RESUMED("8", "已恢复"),
    STOPPED("9", "已停止");
    
    private final String code;
    private final String description;
    
    MonitoringTaskStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public static MonitoringTaskStatus fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (MonitoringTaskStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }
    
    public static MonitoringTaskStatus fromDescription(String description) {
        if (description == null) {
            return null;
        }
        for (MonitoringTaskStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }
}